#include <iostream>
//#define MYTHREAD
#include "ThreadPool.hpp"
#include "Task.hpp"

#include <unistd.h>
#include <stdlib.h>
#include <time.h>


using namespace std;


template<class T>
struct func
{
    void operator()(T& task)
    {
        task();
        std::cout<<task.calcu()<<task.outcome()<<std::endl;
    }
};

int main()
{

    ThreadPool<Task,func<Task>>::GetCreate()->start();
    ThreadPool<Task,func<Task>>::GetCreate()->check();
    sleep(1);
    char s[] = {'+','-','*','/','%'};
    srand(time(nullptr));

    while(true)
    {
        int i = rand()%1000+1;
        int j = rand()%1000+1;
        int oper = rand()%5;
        Task t(i,j,s[oper]);
        ThreadPool<Task,func<Task>>::GetCreate()->push_task(t);
        cout<<t.calcu()<<"?"<<endl;;
        usleep(100000);
    }
    return 0;
}